package leetcode.code1007;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int minDominoRotations(int[] tops, int[] bottoms) {
		int ans = 20000;
		for (int i = 1; i <= 6; i++) {
			int t = 0, b = 0, j = 0;
			while (j < bottoms.length && (tops[j] == i || bottoms[j] == i)) {
				if (tops[j] != i) {
					t++;
				}
				if (bottoms[j] != i) {
					b++;
				}
				j++;
			}
			if (j == bottoms.length)
				ans = Math.min(ans, Math.min(t, b));
		}
		return ans == 20000 ? -1 : ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
